#include "gc.h"
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <pthread.h>
#include <queue>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>

const int CONST = 10000000;

struct my
{
  int x, y;
  my ()
  {
    x = 0, y = 0;
  }
};
void* ThreadRun(void* params)
{
    //Преобразуем входящие параметры в int*
    int* myNumber = (int*) params;
    std::string start;
    std::string enter;
    std::string leave;
 
    char buff[10];
    sprintf(buff, "%i", *myNumber);
    start.append("Thread["); start.append(buff); start.append("] start...\n");

    std::cout << start.c_str();
    gc_ptr <my> ptr;
    ptr = gc_new <my> (CONST);
    leave.append("Thread["); leave.append(buff); leave.append("] leave critical section...\n");

    std::cout << leave.c_str();
}
int main ()
{
 for (int i = 0; i < 5; ++i)
    {
        //Каждому потоку, в качестве параметра передаем его номер
        int* number = new int;
        number[i] = i;
        //_beginthread(ThreadRun, 0, (void*) number);
        pthread_create((pthread_t *) number, NULL, ThreadRun, number);
    }


 // mark_and_sweep();

cin.ignore().get();
  return 0;
}
